package com.qf.lanzhou.blog.api.controller;

import com.qf.lanzhou.blog.api.pojo.vo.ReplyVo;
import com.qf.lanzhou.blog.api.service.ReplyService;
import com.qf.lanzhou.blog.api.service.impl.ReplyServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author 是柠檬甜
 * @ClassName ReplyShowServlet
 * @description 展示评论功能
 * @date 2020/12/18 15:48
 * @modifier 是柠檬甜
 * @date 2020-12-18 15:48
 * @Version V1.0
 */
@WebServlet("/replyShow.do")
public class ReplyShowServlet extends BaseServletPost {
    private ReplyService replyService=new ReplyServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String articleId = req.getParameter("articleId");
        String commentId = req.getParameter("commentId");
        long articleIdLong = Long.parseLong(articleId);
        long commentIdLong = Long.parseLong(commentId);
        System.out.println(articleId+"========");
        System.out.println(commentIdLong+"===========");
        List<ReplyVo> list = replyService.selectReply(commentIdLong, articleIdLong);
        for (ReplyVo reply:list) {
            reply.setReplyCreatTimeStr(reply.getReplyCreatTime());
            System.out.println(reply);
        }
        System.out.println(list);
        successResultWrite(list,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
